Repository navigation
[ALLOC] Replace malloc_hack with guest-owned allocator model - #4728
Conversation
Keeps guest and host memory ownership separate instead of rewriting guest allocator entry points. The new model detects when an emulated program globally replaces malloc/free, leaves that allocator untouched, and routes guest-visible wrapper allocations through the guest's allocator while box64 and native wrapped libraries stay on the host heap. `free/realloc/usable-size` calls dispatch by pointer provenance, using guest mmap ranges plus an isolated guest brk arena for classification. `BOX64_MALLOC_HACK` and `BOX64_LIBCEF` env vars are removed. Tested: - Node.js with npm - Bun (and Claude code) - Chromium - Electron (and Heroic) - WeChat All working fine.
|
The I is red. The new test seems to be failling. |
|
Yeah, because static-build does not benefit from this. |
|
The idea seems very similar to former malloc_hook, but without the hooking itself, just letting the guest allocator do it's things. Did you try some box32 complex apps/games, and some AppImage (as brk been changed, staticaly linked stuffs might have been impacted). I'm still woried that some direct jump to guest free can be done directly with a native pointer in it. |
|
I tried several AppImages, and they worked well. Box32 should be unaffected, this is 64-bit only. |
Well, yeah, but there is an auto-detection now, so no manual BOX64_DYNAREC_MALLOC_HACK is needed. |
Keeps guest and host memory ownership separate instead of rewriting guest allocator entry points.
The new model detects when an emulated program globally replaces malloc/free, leaves that allocator untouched, and routes guest-visible wrapper allocations through the guest's allocator while box64 and native wrapped libraries stay on the host heap.
free/realloc/usable-sizecalls dispatch by pointer provenance, using guest mmap ranges plus an isolated guest brk arena for classification.BOX64_MALLOC_HACKandBOX64_LIBCEFenv vars are removed.Tested:
All working fine.